
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports _2bMatesSite.BO

Namespace _2bMatesSite
	''' <summary>
	''' Summary description for confirm_photo_description.
	''' </summary>
	Public Partial Class confirm_photo_description
		Inherits BaseWebPage
		Private grpID As Integer = -1
		Private isGroupMode As Boolean = False
		Private grp As Group = Nothing
		Protected htPageConstants As New Hashtable()

		Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
			' Put user code to initialize the page here
			' this.pageTemplate.PageTitle = PageTitles.CONFIRM_PHOTO_DESCRIPTION_PAGE;

			If LoggedUser = Nothing Then
				Common.Utils.RedirectToLoginPage(Page)
			End If

			If Request.Params("id") = Nothing OrElse Request.Params("id") = "" Then
				Throw New Exception(Constants.ERROR_MESSAGE_MISSING_PARAMETERS)
			End If

			' init page from XML
			Me.initPageTitles(Constants.CONFIRM_PHOTO_DESCRIPTION, "", Form1, Nothing, htPageConstants)
			Me.initAdvertisements(Form1, Nothing)

			If Constants.SHOW_GROUPS <> Constants.SHOW_ON Then
				Throw New Exception(Constants.ERROR_MESSAGE_NO_ACCESS)
			End If

			' init group
			If Request.Params(Constants.GROUP_PARAM) <> Nothing AndAlso Request.Params(Constants.GROUP_PARAM) <> "" Then
				isGroupMode = True
				grpID = Convert.ToInt32(Request.Params(Constants.GROUP_PARAM))
				grp = Groups.GetGroupByID(grpID)
				If grp = Nothing Then
					Throw New Exception(Constants.ERROR_MESSAGE_MISSING_PARAMETERS)
				End If
			End If

			If isGroupMode Then
				hlBackToGroup.NavigateUrl = "../" + Constants.GROUP_WELCOME + "?" + Constants.GROUP_PARAM + "=" + grpID
				hlBackToGroup.Text = (Me.GetPageConstText(htPageConstants, "CONST_GroupBackLink_TEXT")).Replace("[PARAM]", grp.Name)
			End If

			lblDescription.Text = ""

			If Request.QueryString("desc") <> Nothing AndAlso Request.QueryString("desc") <> "" Then
				lblDescription.Text = Request.QueryString("desc").ToString()
			End If

			If lblDescription.Text.Length > 50 Then
				lblDescription.Text = lblDescription.Text.Substring(0, 50)
			End If
			' set the maxlength
			'lblDescription.Text = Request.Cookies.Get("desc").Value;
			btnCancel.Attributes("onclick") = "javascript: history.back(); return false;"
		End Sub

		#region Web Form Designer generated code
		Protected Overloads Overrides Sub OnInit(ByVal e As EventArgs)
			'
			' CODEGEN: This call is required by the ASP.NET Web Form Designer.
			'
			InitializeComponent()
			MyBase.OnInit(e)
		End Sub

		''' <summary>
		''' Required method for Designer support - do not modify
		''' the contents of this method with the code editor.
		''' </summary>
		Private Sub InitializeComponent()

		End Sub
#End Region

		Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs)
			Dim imgID As Integer = Convert.ToInt32(Request.Params("id"))

			If isGroupMode Then
				Dim pic As GroupPicture = grp.GetPicture(imgID)
				pic.Desc = lblDescription.Text
				pic.Save()
				Response.Redirect(Constants.UPLOAD_GROUP_PHOTO + "?" + Constants.GROUP_PARAM + "=" + grp.ID)
			Else
				Dim pic As UserPicture = LoggedUser.GetPicture(imgID)
				pic.Desc = lblDescription.Text
				pic.Save()
				Response.Redirect(Constants.UPLOAD_PHOTO)
			End If
		End Sub

		====================
        ' This public property was added by conversion wizard to allow the access of a protected, autogenerated member variable Form1.
		====================
        Public ReadOnly Property Form1() As System.Web.UI.HtmlControls.HtmlForm
            Get
                Return Migrated_Form1
            End Get
        End Property
        'set { Migrated_Form1 = value; }
    End Class
End Namespace






